<?php
echo '<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>Install - Code By DaiJava</title><body>';
require_once ("./in/data.php");
switch ($_GET ['in']) {
	default :
		echo '<br><b style="color:red">&bull;</b>Trước khi install bạn hãy kiểm tra database để chắc rằng database sạch. Không lẫn hoặc dùng chung với database khác.<br><br><b style="color:red">&bull;</b>Bắt Đầu Cài Đặt<br><form action="?in=install" method="post">&bull;Nick Admin:<br><input type="text" name="nick" value="Admin" size="15"><br>&bull;Mật Khẩu:<br><input type="password" name="pass" size="15"><br>&bull;Nhập Lại Mật Khẩu:<br><input type="password" name="pass2" size="15"><br>&bull;EMail:<br><input type="text" name="email" value="@" size="15"><br>&bull;Trang Chủ( không có / ở cuối):<br><input type="text" name="home" value="http://" size="15"><br>&bull;Tên Wap:<br><input type="text" name="cp" value="ĐạiJava" size="15"><br><input type="submit" value="Bắt Đầu"></form>';
		break;
	case 'install' :
		$nick = addslashes ( $_POST ['nick'] );
		$pass = md5 ( addslashes ( $_POST ['pass'] ) );
		$pass2 = md5 ( addslashes ( $_POST ['pass2'] ) );
		$email = addslashes ( $_POST ['email'] );
		$cp = addslashes ( $_POST ['cp'] );
		$home = $_POST ['home'];
		if (empty ( $nick ) || empty ( $pass ) || empty ( $pass2 ) || empty ( $email ) || empty ( $home ) || empty ( $cp )) {
			echo '<img src="../img/loi.png">Bạn không được để trống phần nào.!<br><a href="?">Quay lại</a>';
		} elseif ($pass != $pass2) {
			echo '<img src="../img/loi.png">2 Mật khẩu không giống nhau.!<br><a href="?">Quay lại</a>';
		} else {
			@mysql_query ( "DROP TABLE IF EXISTS `caidat`;" );
			$caidat = @mysql_query ( "CREATE TABLE `caidat` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`home` varchar(50) NOT NULL,
`dangki` varchar(5) NOT NULL,
`chat` varchar(50) NOT NULL,
`cp` varchar(50) NOT NULL,
`key` varchar(500) NOT NULL,
`taive` varchar(5) NOT NULL,
`tit` varchar(10) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;" );
			if ($caidat) {
				echo 'Table <b style="color:green">caidat</b> Hoàn Tất<br>';
			} else {
				echo 'Table <b style="color:red">caidat</b> Thất Bại<br>';
			}
			@mysql_query ( "INSERT INTO `caidat` VALUES(1, '" . $home . "', 'op', 'op', '" . $cp . "', 'Code Wap PorTal By MrTâm', 'op', 'MrTam');" );
			@mysql_query ( "DROP TABLE IF EXISTS `tlgame`;" );
			$tlgame = @mysql_query ( "CREATE TABLE `tlgame` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `theloai` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;" );
			if ($tlgame) {
				echo 'Table <b style="color:green">tlgame</b> Hoàn Tất<br>';
			} else {
				echo 'Table <b style="color:red">tlgame</b> Thất Bại<br>';
			}
			@mysql_query ( "INSERT INTO `tlgame` VALUES(1, 'Thể Loại Khác');" );
			@mysql_query ( "DROP TABLE IF EXISTS `taikhoan`;" );
			$taikhoan = @mysql_query ( "CREATE TABLE `taikhoan` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `nick` varchar(20) NOT NULL,
  `password` varchar(200) NOT NULL,
  `email` varchar(50) NOT NULL,
  `quyen` int(10) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;" );
			if ($taikhoan) {
				echo 'Table <b style="color:green">taikhoan</b> Hoàn Tất<br>';
			} else {
				echo 'Table <b style="color:red">taikhoan</b> Thất Bại<br>';
			}
			@mysql_query ( "INSERT INTO `taikhoan` VALUES(1, '" . $nick . "', '" . $pass . "', '" . $email . "', '2');" );
			@mysql_query ( "DROP TABLE IF EXISTS `game`;" );
			$game = @mysql_query ( "CREATE TABLE `game` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `tieude` varchar(100) NOT NULL,
  `manhinh` varchar(20) NOT NULL,
  `sanxuat` varchar(200) NOT NULL,
  `mota` varchar(5000) NOT NULL,
  `theloai` varchar(5000) NOT NULL,
  `thoigian` varchar(200) NOT NULL,
`link` varchar(5000) NOT NULL,
`icon` varchar(5000) NOT NULL,
`thich` int(250) NOT NULL DEFAULT '0',
`down` int(250) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;" );
			if ($game) {
				echo 'Table <b style="color:green">game</b> Hoàn Tất<br>';
			} else {
				echo 'Table <b style="color:red">game</b> Thất Bại<br>';
			}
			@mysql_query ( "DROP TABLE IF EXISTS `online`;" );
			$online = @mysql_query ( "CREATE TABLE `online` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `ten` varchar(20) NOT NULL,
  `ip` varchar(200) NOT NULL,
  `time` varchar(200) NOT NULL,
  `dt` varchar(50) NOT NULL,
   `url` varchar(500) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;" );
			if ($online) {
				echo 'Table <b style="color:green">online</b> Hoàn Tất<br>';
			} else {
				echo 'Table <b style="color:red">online</b> Thất Bại<br>';
			}
			@mysql_query ( "DROP TABLE IF EXISTS `chat`;" );
			$chat = @mysql_query ( "CREATE TABLE `chat` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `ten` varchar(20) NOT NULL,
  `noidung` varchar(500) NOT NULL,
  `thoigian` varchar(200) NOT NULL,
  `ip` varchar(50) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;" );
			if ($chat) {
				echo 'Table <b style="color:green">chat</b> Hoàn Tất<br>';
			} else {
				echo 'Table <b style="color:red">chat</b> Thất Bại<br>';
			}
			@mysql_query ( "DROP TABLE IF EXISTS `spam`;" );
			$spam = @mysql_query ( "CREATE TABLE `spam` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `ten` varchar(20) NOT NULL,
  `time` varchar(200) NOT NULL,
  `ip` varchar(500) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;" );
			if ($spam) {
				echo 'Table <b style="color:green">spam</b> Hoàn Tất<br>';
			} else {
				echo 'Table <b style="color:red">spam</b> Thất Bại<br>';
			}
			@mysql_query ( "DROP TABLE IF EXISTS `giohang`;" );
			$giohang = @mysql_query ( "CREATE TABLE `giohang` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `ten` varchar(500) NOT NULL,
  `idgame` varchar(5000) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;" );
			if ($giohang) {
				echo 'Table <b style="color:green">giohang</b> Hoàn Tất<br>';
			} else {
				echo 'Table <b style="color:red">giohang</b> Thất Bại<br>';
			}
			@mysql_query ( "DROP TABLE IF EXISTS `dggame`;" );
			$dggame = @mysql_query ( "CREATE TABLE `dggame` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `ip` varchar(500) NOT NULL,
  `idgame` varchar(5000) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;" );
			if ($dggame) {
				echo 'Table <b style="color:green">dggame</b> Hoàn Tất<br>';
			} else {
				echo 'Table <b style="color:red">dggame</b> Thất Bại<br>';
			}
			//-install xong-//
			$sql_query = @mysql_query ( "SELECT id FROM taikhoan WHERE nick='{$nick}'" );
			$taikhoan = @mysql_fetch_array ( $sql_query );
			@session_start ();
			$_SESSION ['user_id'] = $taikhoan ['id'];
			echo '<hr><br>&bull;Bạn đã Install xong. Nếu có một hay nhiều Table <b style="color:red">thất bại</b> thì hãy kiểm tra database và tiến hành install lại nhé.<br>&bull;Nếu install thành công Hãy ấn tiếp tục để cài đặt thêm cho hệ thống nhé.! Àk nhớ xóa file ins.php này nha.!<br><a href="cpanel.php">Tiếp Tục</a><br><br>';
		}
		break;
}
echo '</body></html>';
?>